package idv.loveloser.mobilemoodle;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CourseManagerAdapter extends BaseAdapter {
	private List<MdlCourse> courses;
	private LayoutInflater mInflater;
	private Context mContext;
	public CourseManagerAdapter(Context context){
		this.mContext = context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return courses.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CourseViewHolder holder =null;
		this.mInflater = LayoutInflater.from(mContext); 
		if (convertView == null) {
			holder=new CourseViewHolder();   
			convertView = mInflater.inflate(R.layout.course_holder, null);
			holder.courseImageView = (ImageView) convertView.findViewById(R.id.courseIcon);
			holder.courseTextView = (TextView) convertView.findViewById(R.id.courseDescription);
			convertView.setTag(holder); 
		}else{
			holder = (CourseViewHolder)convertView.getTag(); 
		}
		holder.courseTextView.setText(courses.get(position).getFullname());
		return convertView;
	}

	public List<MdlCourse> getCourses() {
		return courses;
	}

	public void setCourses(List<MdlCourse> courses) {
		this.courses = courses;
	}

}
